package com.neusoft.controller;

import com.neusoft.entity.BanJi;
import com.neusoft.service.BanjiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("banji")
public class BanjiController {
    @Autowired
    private BanjiService banjiService;

    @PostMapping("insert")
    public Object insert(BanJi bean) {
        return banjiService.insert(bean);
    }

    @GetMapping("queryAll")
    public Object queryAll() {
        return banjiService.queryAll();
    }

    @GetMapping("queryById/{id}")
    public Object queryById(@PathVariable Integer id) {
       BanJi banji = banjiService.queryById(id);
       if(banji == null){
           throw new RuntimeException("出错了，没有该id");
       }
        return banji;
    }
}
